package com.sptus.system.domain.vo;

import lombok.Data;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
public class WorkFlowVO {
    String status;
    String account;
    boolean isComplete=false;
    String userId;
    String  createTime;
     static SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");

    public  static  WorkFlowVO   newCreateWorkFlowVO  (String account,String userId){
        WorkFlowVO workFlowVO = new WorkFlowVO();
        workFlowVO.setStatus("Create Order");
        workFlowVO.setAccount(account);
        workFlowVO.setComplete(true);
        workFlowVO.setUserId(userId);
        workFlowVO.setCreateTime(formatter.format(new Date()));
        return workFlowVO;
    };
    public  static  WorkFlowVO   newProgressWorkFlowVO  (String account,String userId){
        WorkFlowVO workFlowVO = new WorkFlowVO();
        workFlowVO.setStatus("being processed");
//        workFlowVO.setAccount(account);
//        workFlowVO.setUserId(userId);
//        workFlowVO.setCreateTime(formatter.format(new Date()));
        return workFlowVO;
    };
    public  static  WorkFlowVO   newSuSpendFlowVO  (String account,String userId){
        WorkFlowVO workFlowVO = new WorkFlowVO();
        workFlowVO.setStatus("SuSpend");
//        workFlowVO.setAccount(account);
//        workFlowVO.setUserId(userId);
//        workFlowVO.setCreateTime(formatter.format(new Date()));
        return workFlowVO;
    };
    public  static  WorkFlowVO   newDoneWorkFlowVO  (String account,String userId){
        WorkFlowVO workFlowVO = new WorkFlowVO();
        workFlowVO.setStatus("Done");
//        workFlowVO.setAccount(account);
//        workFlowVO.setUserId(userId);
//        workFlowVO.setCreateTime(formatter.format(new Date()));
        return workFlowVO;
    };
    public static ArrayList<WorkFlowVO> newListWorkFlowVO(String account,String userId){
        ArrayList<WorkFlowVO> workFlowVOS = new ArrayList<>();
        workFlowVOS.add(newCreateWorkFlowVO(account,userId));
        workFlowVOS.add(newProgressWorkFlowVO(account,userId));
        workFlowVOS.add(newDoneWorkFlowVO(account,userId));
        return workFlowVOS;
    };

    public  static WorkFlowVO   saveWorkFlowVO(String status,String account,String userId){
        if(status.equals("Suspend")){
            return  newSuSpendFlowVO(account,userId);
        }else if(status.equals("To Do")){

            return  newCreateWorkFlowVO(account,userId);
        }else if(status.equals("In Progress")){
            return  newProgressWorkFlowVO(account,userId);
        }else {
            return  newDoneWorkFlowVO(account,userId);
        }
    }
    public  static List<WorkFlowVO>    updateWorkFlowVO(List<WorkFlowVO> workFlowVOS, String status, String account, String userId){
        if(status.equals("Suspend")){
//            return  newSuSpendFlowVO(account,userId);
        }else if(status.equals("To Do")){
            workFlowVOS.get(0).setAccount(account);
            workFlowVOS.get(0).setUserId(userId);
            workFlowVOS.get(0).setComplete(true);
            workFlowVOS.get(0).setCreateTime(formatter.format(new Date()));
        }else if(status.equals("In Progress")){
            workFlowVOS.get(1).setAccount(account);
            workFlowVOS.get(1).setUserId(userId);
            workFlowVOS.get(1).setComplete(true);
            workFlowVOS.get(1).setCreateTime(formatter.format(new Date()));
        }else {
            workFlowVOS.get(2).setAccount(account);
            workFlowVOS.get(2).setUserId(userId);
            workFlowVOS.get(2).setComplete(true);
            workFlowVOS.get(2).setCreateTime(formatter.format(new Date()));
        }

        return workFlowVOS;
    }
}
